<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ page import="myschool.entity.Student" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="myschool.mybatisUtil.MybatisUtil" %>
<%@ page import="myschool.dao.StudentDao" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/6/5
  Time: 20:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
    SimpleDateFormat sd= new SimpleDateFormat("yy-mm-dd");
    String sname=request.getParameter("sname");
    String sex = request.getParameter("sex");
    String telephone = request.getParameter("telephone");
    String qq = request.getParameter("qq");
    String weChat = request.getParameter("weChat");
    String gradeID = request.getParameter("gradeID");
    Date d1 = sd.parse(request.getParameter("date"));
    Date d2 = sd.parse(request.getParameter("birthday"));
    String city = request.getParameter("city");
    String address = request.getParameter("address");
    String pwd = request.getParameter("pwd");
    String idCardPic = request.getParameter("idCardPic");

    Student student = new Student();
    student.setSname(sname);
    student.setSex(sex);
    student.setTelephone(telephone);
    student.setQq(qq);
    student.setWechat(weChat);
    student.setGradeid(Integer.parseInt(gradeID));
    student.setEnterdate(d1);
    student.setBirthday(d2);
    student.setFromcity(city);
    student.setAddress(address);
    student.setPass(pwd);
    student.setIdcardpic(idCardPic);

    SqlSession s= MybatisUtil.get();
    StudentDao mapper = s.getMapper(StudentDao.class);
    mapper.add(student);
    MybatisUtil.close(s);
%>
</body>
</html>
